package main

import (
	"fmt"
	"github.com/asaskevich/govalidator"
	"gorm.io/gorm"
)

// go get github.com/asaskevich/govalidator
type UserBasic struct {
	gorm.Model
	Name     string
	PassWord string
	Phone    string `valid:"matches(^1[3-9]{1}//d{9}$)"`
	Email    string `valid:"email"`
}

func main() {
	_, err := govalidator.ValidateStruct(UserBasic{}) //校验结构体
	if err != nil {
		fmt.Println("效验失败", err)
	}
}
